<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------

namespace app\common\validate;

/**
* 设置模型
*/
class Option extends Base{

    protected $rule = array(
        'id'  =>  'require|unique3',
        // 'pid'  =>  'require',
        'name' =>  'require',
    );

    // protected $message = array(
    //     'name.require'  =>  '规则标识必须',
    //     'name.unique'   =>  '规则标识已经存在',
    //     'title'         =>  '规则名称必须',
    // );

    protected $scene = array(
        'add'   => array('id', 'name'),
        'upt'  => array('name')
    );

    public function unique3($value,$rule,$data , $a ,$b ){
        $rs = db('option')->find($value);
        if( !!$rs ){ return 'id已存在！';}
        return true; //验证通过
    }

}